package com.xhlj.service.impl;

import com.alibaba.fastjson2.util.DateUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xhlj.entity.UserInfo;
import com.xhlj.service.UserInfoService;
import com.xhlj.mapper.UserInfoMapper;
import com.xhlj.utils.PayLoad;
import com.xhlj.utils.Result;
import com.xhlj.utils.UserType;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author dell
 * @description 针对表【user_info】的数据库操作Service实现
 * @createDate 2024-03-01 11:48:33
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
        implements UserInfoService {

    /*
     * 通过Username获取token所应该携带的的载荷
     * @param username
     * @return PayLoad
     **/
    @Resource
    private UserInfoMapper userInfoMapper;

    public PayLoad createPayLoad(String username) {
        LambdaQueryWrapper<UserInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserInfo::getUserPhone, username);
        UserInfo userInfo = userInfoMapper.selectOne(wrapper);
        PayLoad payLoad = new PayLoad(userInfo.getUserPhone(), UserType.fromValue(userInfo.getUserType()), userInfo.getUserId());
        return payLoad;
    }


    public Result sign(String username) {
        return null;
    }
}




